import JSEncrypt from 'jsencrypt/bin/jsencrypt';
import CryptoJS from 'crypto-js';

function encryption() {
	var encrypt = new JSEncrypt();
	encrypt.setPublicKey(
		"-----BEGIN PUBLIC KEY-----MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDC8aDOEKm1aPcNgLONeJO+syijflgXZDJoSAlK69pIH4opaIOwginspTpyFhUGSM9VlwSUighmvYiIWfQHXOy2Fua+5faBy1wgfet1JkqZt3nPIQrGU60HfpXWECvG954dv3EFaXM4NqOdQKyrcCjzbayzu+qG+oqdarG2WfA0+wIDAQAB-----END PUBLIC KEY-----"
	);
	var token = {
		time: parseInt(new Date().getTime() / 1000),
		key: CryptoJS.MD5(String(Math.random())).toString()
	};
	return encrypt.encrypt(JSON.stringify(token));
}
export default encryption;
